<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
	<meta name="format-detection" content="telephone=no">
	<meta name="x5-orientation" content="portrait">
	<meta name="x5-fullscreen" content="true">
	<meta name="full-screen" content="yes">
	<title>分期缴费申请</title>
	<link rel="stylesheet" href="../css/style.css">
	<link rel="stylesheet" href="../css/Mdate.css">
	<link rel="stylesheet" type="text/css" href="../css/common.css" />
	<script src="../js/index1.js"></script>
	<script src="../js/rem-config.js"></script>
	<script src="../js/zepto.js"></script>
	<script src="../js/Mdate.js"></script>
	<script src="../js/iscroll.js"></script>
</head>
<body>

<div class="tabbar">
	<a href="mine.html" class="tabbar_r">
		<img src="../images/x.png" >
	</a>
	<span>分期缴费申请</span>
	<a href="" class="tabbar_c">
		<img src="../images/caidan.png" alt="">
	</a>
	<div class="clear"></div>
</div>
<div class="f_banner" style="height:5rem;">
	<img src="../images/banner.jpg" alt="">
</div>
<div class="progress_bar">

</div>
<div class="fqsh_content">
	<ul>
		<li>
			<span>我的课程</span>
			<a href="javascript:;" class="login_kecheng">
				<span class="kecheng_s">请选择</span>
				<img src="../images/right.png" alt="">
			</a>
		</li>
		<li>
			<span>分期金额</span>
			<a href="javascript:;">
				<input type="text" placeholder="请输入分期金额" class="reg_jine">
			</a>
		</li>
		<li>
			<span>还款周期</span>
			<a href="javascript:;" class="login">
				<span class="login_h">请选择</span>
				<img src="../images/right.png" alt="">
			</a>
		</li>
		<li>
			<span>上课时间</span>
			<a href="javascript:;" class="demo">
				<input type="text" id="dateSelectorOne" placeholder="选择日期" class="reg_time">
			</a>
		</li>

	</ul>
</div>
<div class="fqsh_nextbtn">下一步</div>
<div class="dialog kecheng">
	<div class="dialog_bg"></div>
	<div class="dialog_info">
		<ul>
			<li>java开发工程师</li>
			<li>java开发工程师</li>
			<li>java全栈开发工程师</li>
		</ul>
		<a href="javascript:;" class="dialog_btn kecheng_cancle">取消</a>
	</div>
</div>
<div class="dialog zhouqi">
	<div class="dialog_bg"></div>
	<div class="dialog_info">
		<ul>
			<li>6+12个月</li>
			<li>6+18个月</li>
			<li>12个月</li>
		</ul>
		<a href="javascript:;" class="dialog_btn cancle">取消</a>
	</div>
</div>
<div class="msg"></div>
</body>
<script src="../js/jquery.js"></script>
<script src="../js/iScroll.js"></script>
<script type="text/javascript">
    new Mdate("dateSelectorOne");
</script>
<script>
    $(function() {

        $(".login").click(function() {
            $(".zhouqi").show();
            $.ajax({
                url:appPath+"huankuanDropdownBox",
                data:"",
                dataType:'json',//服务器返回json格式数据
                type:'get',//HTTP请求类型
                success:function(res){
                    if(res.success){
                        var _list = res.data;
                        var _li = "";
                        for(var i = 0;i<_list.length;i++){
                            _li+="<li li_id="+_list[i].id+">"+_list[i].name+"</li>";

                        }
                        $(".dialog.zhouqi ul").html(_li);

                    }else{
                        $(".msg").show().text("获取失败！原因"+res.errorMessage);
                        setTimeout(function(){
                            $(".msg").hide("slow")
                        },2000)
                    }
                }
            });
        })
        $(".cancle").click(function() {
            $(".zhouqi").hide();
        })
        $('.login_kecheng').click(function() {
            $(".kecheng").show();
            $.ajax({
                url:appPath+"kechengDropdownBox",
                data:"",
                dataType:'json',//服务器返回json格式数据
                type:'get',//HTTP请求类型
                success:function(res){
                    if(res.success){
                        var _list = res.data;
                        var _li = "";
                        for(var i = 0;i<_list.length;i++){
                            _li+="<li li_id="+_list[i].id+">"+_list[i].name+"</li>";

                        }
                        $(".dialog.kecheng ul").html(_li);

                    }else{
                        $(".msg").show().text("获取失败！原因"+res.errorMessage);
                        setTimeout(function(){
                            $(".msg").hide("slow")
                        },2000)
                    }
                }
            });
        })
        $('.kecheng_cancle').click(function() {
            $(".kecheng").hide();
        })

        // 获取文字再放上去
        $(".dialog").on("click","li",function() {
            var li_text = $(this).text();
            var li_id = $(this).attr("li_id")
            if ($(this).parent().parent().parent().hasClass("kecheng")) {
                $(".login_kecheng span").text(li_text);
                $(".login_kecheng span").attr("li_id",li_id);

            } else {
                $(".login span").text(li_text);
                $(".login span").attr("li_id",li_id);
            }
            $(".dialog").hide();
        })
        //点击事件,发送请求
        $('.fqsh_nextbtn').click(function(){
            var _jine = $('.reg_jine').val();
            var _time = $('.reg_time').val();
            var _kecheng_s = $('.kecheng_s').attr("li_id");
            var _zhouqi = $('.login_h').attr("li_id");
            var _data = {
                "myCourse":parseInt(_kecheng_s),
//                "_login_h":_login_h,
                "amountInstallments":parseInt(_jine),
                "paymentCycle":parseInt(_zhouqi),
                "classHours":_time
            }
				$.ajax({
					url:appPath+"installmentApply",
                    data:JSON.stringify(_data),
                    contentType: "application/json;charset=utf-8",
					dataType:'json',//服务器返回json格式数据
					type:'post',//HTTP请求类型
					success:function(data){
						if(data.success){
							$('.msg').show().text("成功！1秒后跳转")
                            window.location.href="news.html";
						}else{
							$('.msg').show().text('失败！原因'+data.errorMessage)
							setTimeout(function(){
								$('.msg').hide("slow")
							},2000)
						}
					},
					
				});
				
			})
			
			
			
		})
	</script>

</html>
